#include<iostream>
#include<algorithm>
using namespace std;
struct Stu{
	int s;
	string n;
}arr[120];
bool cmp(struct Stu s1,struct Stu s2){
	return s1.s > s2.s;
}
int main(){
	int n = 0;
	cin >> n;
	for(int i = 0 ;i < n; i++){
		cin >> arr[i].s >> arr[i].n;
	}
	sort(arr,arr+n,cmp);
	cout << arr[0].n;
	return 0;
}
